<template>
  <div class="app-container">
    <div class="icons-container">
      <el-tabs type="border-card">
        <el-tab-pane label="Icons">
          <div class="grid">
            <div v-for="item of svgIcons" :key="item">
              <div class="icon-item" @click="handleClipboard(item, $event)">
                <svg-icon :icon-class="item" class-name="disabled" />
                <span>{{ item }}</span>
              </div>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="Element-UI Icons">
          <div class="grid">
            <div v-for="item of elementIcons" :key="item">
              <div class="icon-item" @click="handleClipboard(item, $event)">
                <component :is="ElementPlusIconsVue[item]" class="el-icon"></component>
                <span>{{ item }}</span>
              </div>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script setup lang="ts" name="icons">
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import clipboard from '@/utils/clipboard'
import svgIcons from './svg-icons'

const generateIconCode = (symbol: string) => {
  return `<svg-icon icon-class="${symbol}" />`
}

const handleClipboard = (text, event) => {
  clipboard(text, event)
}

const elementIcons = reactive([])
onMounted(() => {
  Object.keys(ElementPlusIconsVue).map(name => {
    elementIcons.push(name)
  })
})

</script>

<style lang="scss" scoped>
.icons-container {
  overflow: hidden;

  .grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .icon-item {
    margin: 20px;
    height: 85px;
    text-align: center;
    width: 100px;
    float: left;
    font-size: 30px;
    color: #24292e;
    cursor: pointer;
    .el-icon{
      font-size: 24px;
    }
  }

  span {
    display: block;
    font-size: 14px;
    margin-top: 10px;
  }
}
</style>
